﻿using MediatR;
using W.Product.Domain.Dto;
using W.Product.Domain.Product;
using W.Product.Read.API.Appliaction.Command.ProductTypeCommand;
using W.Product.Repository.Interface;

namespace W.Product.Read.API.Appliaction.CommHandler.ProductTypeCommandHandler
{

    public class ProductTypeSelCommandHandler : IRequestHandler<ProductTypeSelCommand, List<ProductType>>
    {
        private readonly IProductTypeRepository _repository;
        public ProductTypeSelCommandHandler(IProductTypeRepository repository)
        {
            _repository = repository;
        }
        /// <summary>
        /// 显示产品类别
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref=""></exception>
        public async Task<List<ProductType>> Handle(ProductTypeSelCommand request, CancellationToken cancellationToken)
        {

            var list=(await _repository.GetAll()).Where(x=>x.IsDelete==false).ToList();
            return list;
           
        }
    }
}
